package diamondServer.businesslogic.router;

import diamondServer.businesslogic.resource.Resource;
import diamondServer.businesslogic.resource.ResourcesRepository;
import diamondServer.resources.Message;

public class DefaultRouter
	implements Router
{
	
	private ResourcesRepository mResources;
	
	public DefaultRouter(ResourcesRepository resourceRepository)
	{
		mResources = resourceRepository;
	}

	@Override
	public void route(Message message) 
		throws RouterException
	{
		Resource r = mResources.getResource( message.getResourceName() );
		if (null == r)
			throw new RouterException();
		r.getService().provide(message);
	}

}
